﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAnalyticsTools.Models
{
    /// <summary>
    /// 异常点详细信息
    /// </summary>
    public class AnomalyPoint
    {
        /// <summary>
        /// 异常点索引
        /// </summary>
        public int Index { get; set; }

        /// <summary>
        /// 异常点的值
        /// </summary>
        public float Value { get; set; }

        /// <summary>
        /// 异常分数
        /// </summary>
        public float Score { get; set; }

        /// <summary>
        /// 异常类型
        /// </summary>
        public AnomalyType Type { get; set; }

        public string AnomalyTypeLabel
        {
            get
            {
                return Type.ToString();
            }
        }

        /// <summary>
        /// 偏离程度（与正常值的偏离倍数）
        /// </summary>
        public float Deviation { get; set; }

        /// <summary>
        /// 异常等级
        /// </summary>
        public string SeverityLevel
        {
            get
            {
                if (Score >= 4.0f) return "严重异常";
                if (Score >= 3.0f) return "高度异常";
                if (Score >= 2.0f) return "中度异常";
                return "轻度异常";
            }
        }

        /// <summary>
        /// 异常原因分析
        /// </summary>
        public string Reason { get; set; }
    }

    /// <summary>
    /// 异常类型枚举
    /// </summary>
    public enum AnomalyType
    {
        /// <summary>
        /// 高于正常范围
        /// </summary>
        High,

        /// <summary>
        /// 低于正常范围
        /// </summary>
        Low,

        /// <summary>
        /// 突变点
        /// </summary>
        Spike,

        /// <summary>
        /// 其他类型异常
        /// </summary>
        Other
    }
}
